package com.tchintech.pay.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tchintech.pay.R;
import com.tchintech.pay.model.entity.Bank;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/8/7 0007.
 */

public class BankListAdapter extends BaseAdapter {

    private Context context;
    private List<Bank> list=new ArrayList<Bank>();

    public BankListAdapter(Context context, List<Bank> list){
        this.context=context;
        this.list=list;

    }

    public void  setList(List<Bank>  list){
        if(list==null){
            this.list=new ArrayList<Bank>();
        }else{
            this.list=list;
        }
        notifyDataSetChanged();
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Bank getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        ViewHolde vh=null;
        if(v==null){
            vh=new ViewHolde();
            v= LayoutInflater.from(context).inflate(R.layout.adapter_bank,null);
            vh.bankname= (TextView) v.findViewById(R.id.tv_bankname);
            v.setTag(vh);
        }else{
            vh= (ViewHolde) v.getTag();
        }
        Bank bank=list.get(position);
        vh.bankname.setText(bank.getBankName());
        return v;
    }

    class ViewHolde{
        TextView bankname;


    }
}
